define(["jQuery", "kendo"], function ($, kendo) {
    return {
    	creationMode:false,
		selectedList:false,
		listItemCount:0,
		radioChartVal : false,
		widthChart : 350,
		heightChart : 250,
		btnEnable : false,
		imgIdTemp : false,
		editClick : false,
		charData : [],
		fillColor : [],
		gradient : 0,
		scale90 : 0,
		isOpen	: 0,
		isInitialRadio:0,
		startColor : false,
		endColor : false,
		
		show : function(){
			var center = App.getAbsoluteCenter();
			
			center.x -= (Math.floor($( "#chart-dragable-menu").width()/2) - $("#rootContainer").offset().left);
			center.y -= (Math.floor($( "#chart-dragable-menu").height()/2) - $("#rootContainer").offset().top);
			
			$( "#chart-dragable-menu").css('left', center.x);
			$( "#chart-dragable-menu").css('top', center.y);
			$( "#chart-dragable-menu" ).show();	
			
			if(!App.chartToolbox.editClick){
				// $("#y").removeAttr("checked");
				$("#x-axis").attr("checked", "checked")
				$("#bar").attr("checked", "checked")
				$("#bar-choose").attr("checked", "checked")
				// $("#gradient").attr("checked", "")
				$("#gradient").prop("checked", false);
				if ($("#bar").attr("checked")) {  	
					$('#bar-start').css('display','block');
					$('#pie-start').css('display','none');	
					$('#pie-chart-start').css('display','none');
					$('#grad-bar').css('display','block');					
					$('#color-grad').css('display','block');
					$('#bar').attr('checked','checked');
					$('#bar-choose').attr('checked','checked');
					$('#3D-choose').removeAttr('checked'); 
					$('#gradient').removeAttr('checked'); 
				}
				$('#3D-choose').removeAttr('checked'); 
					$('#gradient').removeAttr('checked');
			}
		},
		
        init: function (e) {
			var indxList = false;
			App.chartToolbox.isInitialRadio = 0;
			
			$("#chart-dragable-menu").draggable({cancel : '#value-chart, #chart-input-area'});
			$('#value-chart').click( function () {    
				$(this).focus();
			});
			$("#chart-dragable-menu").hide();
			
			
			$('#colorChart').jPicker(
					{
					 window:
						  {
							expandable: true
						  },
						  position:
							{
							  x: 'screenCenter', // acceptable values "left", "center", "right", "screenCenter", or relative px value
							  y: 'top', // acceptable values "top", "bottom", "center", or relative px value
							},
						  images:
						  {
							clientPath : App.baseUrl+'assets/css/images/jPicker/'
						  }
					},
					function(color, context)
					{
					  var all = color.val('all'); 
						App.chartToolbox.fillColor =  '#' + all.hex;				
					}
			);
			
			$('#startColorChart').jPicker(
					{
					 window:
						  {
							expandable: true
						  },
						  images:
						  {
							clientPath : App.baseUrl+'assets/css/images/jPicker/'
						  }
					},
					function(color, context)
					{
					  var all = color.val('all'); 
						App.chartToolbox.startColor =  '#' + all.hex;				
					}
			);
			
			$('#endColorChart').jPicker(
					{
					 window:
						  {
							expandable: true
						  },
						  images:
						  {
							clientPath : App.baseUrl+'assets/css/images/jPicker/'
						  }
					},
					function(color, context)
					{
					  var all = color.val('all'); 
						App.chartToolbox.endColor =  '#' + all.hex;				
					}
			);
		
			$(".chart-tools").click(function() {
				if(!App.toolboxValidation("tool_chart_ico"))
				{
					return;
				}
				$(this).addClass('active');
				App.openedTool = $(this);
				App.setEnableChartCreationMode(true);
				
			});
			
			$(".submit-input-value").click(function() {
				var inputVal = $('#value-chart').val();
				if(!(!isNaN(parseFloat(inputVal)) && isFinite(inputVal)))
				{
					alert(App.localize("%numeric_input_warning"));
				}
				else
				{
					App.chartToolbox.listItemCount++;
					var newListValue = $('<div></div>').attr({'id':App.chartToolbox.listItemCount,'class':'chart-point-box'}).html(inputVal).appendTo($('#list-value'));
					
					newListValue.click(function(e) {
						 
						indxList = e.currentTarget.id; 
						if(App.chartToolbox.selectedList){
							App.chartToolbox.selectedList.attr('class', 'chart-point-box');
						}						
						$(this).attr('class', 'chart-point-box-selected');
						App.chartToolbox.selectedList=$(this);
					});
					App.chartToolbox.charData.push(inputVal);
				}
				$( "#value-chart" ).val('');
			});
			
			$(".delete-row-button").click(function(e) { 
				if (App.chartToolbox.selectedList){
					App.chartToolbox.selectedList.remove();
					App.chartToolbox.selectedList = false; 
					App.chartToolbox.charData.splice({id:indxList});
					var valueList = $( "#list-value" ).find('.chart-point-box').length;
					var i = 0;
					for(i=0;i<valueList;i++){
						App.chartToolbox.charData.push($( "#list-value" ).find($('.chart-point-box')[i]).text());
					}
				}
			});
			
			$(".radio-axis").change(function () {
				var radioAxisVal = "";
				if ($("#x").attr("checked")) {
					radioAxisVal = $('#x').val();
				}
				else if ($("#y").attr("checked")) {
					radioAxisVal = $('#y').val();				
				}
				console.log(radioAxisVal);
            });
			
			
			if ($("#bar").attr("checked")) {  
					$('#bar-start').css('display','block');
					$('#pie-start').css('display','none');	
					$('#pie-chart-start').css('display','none');	 				
					$(".radio-bar-chart").change(function () {
						if ($("#bar-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#bar-choose').val();
							$('#grad-bar').css('display','block');					
							$('#color-grad').css('display','block');
						}else if ($("#line-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#line-choose').val();
							$('#grad-bar').css('display','none');					
							$('#color-grad').css('display','none');
						}
					});
					if ($("#bar-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#bar-choose').val();
							$('#grad-bar').css('display','block');					
							$('#color-grad').css('display','block');
						}else if ($("#line-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#line-choose').val();
							$('#grad-bar').css('display','none');					
							$('#color-grad').css('display','none');
						}
				
			}else if ($("#acc").attr("checked")) { 		
				$('#bar-start').css('display','none'); 
				$('#pie-start').css('display','none'); 
				$('#pie-chart-start').css('display','none');
				$('#grad-bar').css('display','none');					
				$('#color-grad').css('display','none'); 
				App.chartToolbox.radioChartVal = $('#acc').val();
			}else if ($("#pie").attr("checked")) { 		 
				$('#pie-start').css('display','none'); 
				$('#bar-start').css('display','none'); 
				$('#pie-chart-start').css('display','block'); 
				$('#grad-bar').css('display','none');					
				$('#color-grad').css('display','none'); 
				$(".radio-pie-chart").change(function () {
				if ($("#pie-choose").attr("checked")) { 
					$('#pie-start').css('display','block'); 
					$("#pie-start").click(function () { 
						if ($("#3D-choose").attr("checked")){ 
							App.chartToolbox.radioChartVal = $('#3D-choose').val();
						}else{ 
							App.chartToolbox.radioChartVal = $('#pie-choose').val();
						}
					});
					if ($("#3D-choose").attr("checked")){ 
							App.chartToolbox.radioChartVal = $('#3D-choose').val();
					}else{ 
							App.chartToolbox.radioChartVal = $('#pie-choose').val();
					}
				}else if ($("#ring-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#ring-choose').val(); 
							$('#pie-start').css('display','none'); 
						}
				});
				if ($("#pie-choose").attr("checked")) {  
					$('#pie-start').css('display','block'); 
					$("#pie-start").click(function () { 
						if ($("#3D-choose").attr("checked")){ 
							App.chartToolbox.radioChartVal = $('#3D-choose').val();
						}else{ 
							App.chartToolbox.radioChartVal = $('#pie-choose').val();
						}
					});
					if ($("#3D-choose").attr("checked")){ 
							App.chartToolbox.radioChartVal = $('#3D-choose').val();
					}else{ 
							App.chartToolbox.radioChartVal = $('#pie-choose').val();
					}
				}else if ($("#ring-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#ring-choose').val(); 
							$('#pie-start').css('display','none'); 
				}  
				App.chartToolbox.isInitialRadio = 1;
			} 
			
			$(".radio-chart").click(function () { 
				if ($("#bar").attr("checked")) { 
					$('#bar-start').css('display','block'); 
					$('#pie-start').css('display','none');  
					$('#pie-chart-start').css('display','none');
					$(".radio-bar-chart").change(function () {
						if ($("#bar-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#bar-choose').val();
							$('#grad-bar').css('display','block');					
							$('#color-grad').css('display','block');
						}else if ($("#line-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#line-choose').val();
							$('#grad-bar').css('display','none');					
							$('#color-grad').css('display','none');
						}
					});
					if ($("#bar-choose").attr("checked")) {  
						App.chartToolbox.radioChartVal = $('#bar-choose').val();
						$('#grad-bar').css('display','block');					
						$('#color-grad').css('display','block');
					}else if ($("#line-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#line-choose').val();
							$('#grad-bar').css('display','none');					
							$('#color-grad').css('display','none');
					}
					App.chartToolbox.isInitialRadio = 1;
				} else if ($("#acc").attr("checked")) {
					App.chartToolbox.radioChartVal = $('#acc').val();	
					$('#bar-start').css('display','none'); 
					$('#pie-start').css('display','none'); 
					$('#pie-chart-start').css('display','none');
					$('#grad-bar').css('display','none');					
					$('#color-grad').css('display','none');
					App.chartToolbox.isInitialRadio = 1;
				}
				else if ($("#pie").attr("checked")) { 		
					$('#pie-start').css('display','none'); 
					$('#bar-start').css('display','none'); 
					$('#pie-chart-start').css('display','block'); 
					$('#grad-bar').css('display','none');					
					$('#color-grad').css('display','none'); 
					$(".radio-pie-chart").change(function () {
					if ($("#pie-choose").attr("checked")) { 
						$('#pie-start').css('display','block'); 
						$("#pie-start").click(function () { 
							if ($("#3D-choose").attr("checked")){ 
								App.chartToolbox.radioChartVal = $('#3D-choose').val();
							}else{ 
								App.chartToolbox.radioChartVal = $('#pie-choose').val();
							}
						});
						if ($("#3D-choose").attr("checked")){ 
								App.chartToolbox.radioChartVal = $('#3D-choose').val();
						}else{ 
								App.chartToolbox.radioChartVal = $('#pie-choose').val();
						}
					}else if ($("#ring-choose").attr("checked")) {  
								App.chartToolbox.radioChartVal = $('#ring-choose').val(); 
								$('#pie-start').css('display','none'); 
							}
					});
					if ($("#pie-choose").attr("checked")) {  
						$('#pie-start').css('display','block'); 
						$("#pie-start").click(function () { 
							if ($("#3D-choose").attr("checked")){ 
								App.chartToolbox.radioChartVal = $('#3D-choose').val();
							}else{ 
								App.chartToolbox.radioChartVal = $('#pie-choose').val();
							}
						});
						if ($("#3D-choose").attr("checked")){ 
								App.chartToolbox.radioChartVal = $('#3D-choose').val();
						}else{ 
								App.chartToolbox.radioChartVal = $('#pie-choose').val();
						}
					}else if ($("#ring-choose").attr("checked")) {  
								App.chartToolbox.radioChartVal = $('#ring-choose').val(); 
								$('#pie-start').css('display','none'); 
					}else if ($("#3D-choose").attr("checked")){
						if ($("#pie-choose").attr("checked")) {  
							App.chartToolbox.radioChartVal = $('#3D-choose').val();
						}
					} 
					App.chartToolbox.isInitialRadio = 1;
				} 
				console.log(App.chartToolbox.radioChartVal);
            });
						
			$("#3d").click(function() {
				var checkboxVal = "";
				if ($("#3d").attr("checked")) {
					checkboxVal = $('#3d').val();
				}
				else{
					checkboxVal = "uncheck 3d";				
				}
				console.log(checkboxVal);
			});
			
			$(".color-button").click(function() {
				console.log("color line/text");
				App.pickColorToolbox.show();
				var id = "color-line";
				App.pickColor(id);
			});	
			
			$("#gradient").click(function() {
				var checkboxVal = "";
				// if ($("#gradient").attr("checked")) {
					// checkboxVal = $('#gradient').val();
				// }
				// else{
					// checkboxVal = "uncheck gradient";	
					// $("#gradient").removeAttr("checked");
				// } 
				// alert("S");
				if ($("#gradient").is(":checked")) {
					// alert("C");
					App.chartToolbox.gradient = 1;
					checkboxVal = $('#gradient').val();
				}
				else{
					// alert("no");
					App.chartToolbox.gradient = 0;
					checkboxVal = "uncheck gradient";	
					$("#gradient").removeAttr("checked");
				}
				console.log(checkboxVal);
				// alert(App.chartToolbox.gradient);
			});
			
			$(".start-button").click(function() {
				console.log("color start");
				var id = "color-start";
				App.pickColor(id);
			});	
			
			$(".end-button").click(function() {
				console.log("color end");
				var id = "color-end";
				App.pickColor(id);
			});

			$(".width-add-button").click(function() {
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					console.log(App.editClick);
					console.log(App.chartToolbox.btnEnable);
					if(App.chartToolbox.editClick == true)
					{
						console.log("width enter");
						var widthPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
						var subStrWdt = widthPlus.css('width');
						var toRemove = 'px';
						var newWidthPlus = subStrWdt.replace(toRemove, '');
						var newWidthPlusInt = parseInt(newWidthPlus) + 10;
						widthPlus.css("width",newWidthPlusInt);
					}
					else
					{
						console.log("width else");
						if(App.chartToolbox.btnEnable)
						{
							var widthPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
							var subStrWdt = widthPlus.css('width');
							var toRemove = 'px';
							var newWidthPlus = subStrWdt.replace(toRemove, '');
							var newWidthPlusInt = parseInt(newWidthPlus) + 10;
							widthPlus.css("width",newWidthPlusInt);
							
						}else{
							App.chartToolbox.btnEnable = true;
							// var charData = [];
							// var tes = $( "#list-value" ).find('.chart-point-box').length;
							// var i = 0;
							// for(i=0;i<tes;i++){
								// charData.push($( "#list-value" ).find($('.chart-point-box')[i]).text());
							// }
							if(App.chartToolbox.radioChartVal == false){
								App.chartToolbox.radioChartVal = "bar";
							}
							
							// $('#list-value').children().each(function(){ 
								// App.chartToolbox.fillColor.push("#"+$(this).attr('hexcolor'));
							// });
						
							App.chartToolbox.imgIdTemp = App.addChartToServer(App.chartToolbox.charData,App.chartToolbox.radioChartVal,App.lastClickPoint.x,App.lastClickPoint.y, App.chartToolbox.widthChart, App.chartToolbox.heightChart, App.chartToolbox.fillColor);
						}
					}
				}
			});	
			
			$(".width-min-button").click(function() {
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					if(App.chartToolbox.editClick)
					{
						console.log("enter");
						var widthMin = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
						var subStrWdt = widthMin.css('width');
						var toRemove = 'px';
						var newWidthMin = subStrWdt.replace(toRemove, '');
						var newWidthMinInt = parseInt(newWidthMin) - 10;
						widthMin.css("width",newWidthMinInt);
					}
					else
					{
						if(App.chartToolbox.btnEnable)
						{
							var widthMin = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
							var subStrWdt = widthMin.css('width');
							var toRemove = 'px';
							var newWidthMin = subStrWdt.replace(toRemove, '');
							var newWidthMinInt = parseInt(newWidthMin) - 10;
							widthMin.css("width",newWidthMinInt);
							
						}else{
							App.chartToolbox.btnEnable = true;
							// var charData = [];
							// var tes = $( "#list-value" ).find('.chart-point-box').length;
							// var i = 0;
							// for(i=0;i<tes;i++){
								// charData.push($( "#list-value" ).find($('.chart-point-box')[i]).text());
							// }
							if(App.chartToolbox.radioChartVal == false){
								App.chartToolbox.radioChartVal = "bar";
							}
							
							// $('#list-value').children().each(function(){ 
								// App.chartToolbox.fillColor.push("#"+$(this).attr('hexcolor'));
							// });
						
							App.chartToolbox.imgIdTemp = App.addChartToServer(App.chartToolbox.charData,App.chartToolbox.radioChartVal,App.lastClickPoint.x,App.lastClickPoint.y, App.chartToolbox.widthChart, App.chartToolbox.heightChart,App.chartToolbox.fillColor);
						}
					}
				}
			});	
			
			$(".height-add-button").click(function() {
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					console.log(App.chartToolbox.editClick);
					if(App.chartToolbox.editClick)
					{
						console.log("enter");
						var heighPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
						var subStrHgh = heighPlus.css('height');
						var toRemoveHeight = 'px';
						var newHeighPlus = subStrHgh.replace(toRemoveHeight, '');
						var newHeighPlusInt = parseInt(newHeighPlus) + 10;
						heighPlus.css("height",newHeighPlusInt);
					}
					else
					{
						if(App.chartToolbox.btnEnable)
						{
							var heighPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
							var subStrHgh = heighPlus.css('height');
							var toRemoveHeight = 'px';
							var newHeighPlus = subStrHgh.replace(toRemoveHeight, '');
							var newHeighPlusInt = parseInt(newHeighPlus) + 10;
							heighPlus.css("height",newHeighPlusInt);
							
						}else{
							App.chartToolbox.btnEnable = true;
							// var charData = [];
							// var tes = $( "#list-value" ).find('.chart-point-box').length;
							// var i = 0;
							// for(i=0;i<tes;i++){
								// charData.push($( "#list-value" ).find($('.chart-point-box')[i]).text());
							// }
							if(App.chartToolbox.radioChartVal == false){
								App.chartToolbox.radioChartVal = "bar";
							}
							
							// $('#list-value').children().each(function(){ 
								// App.chartToolbox.fillColor.push("#"+$(this).attr('hexcolor'));
							// });
						
							App.chartToolbox.imgIdTemp = App.addChartToServer(App.chartToolbox.charData,App.chartToolbox.radioChartVal,App.lastClickPoint.x,App.lastClickPoint.y, App.chartToolbox.widthChart, App.chartToolbox.heightChart,App.chartToolbox.fillColor);
						}
					}
				}
			});	
			
			$(".height-min-button").click(function() {
				console.log("height min");
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					if(App.chartToolbox.editClick)
					{
						console.log("enter");
						var widthPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
						var subStrWdt = widthPlus.css('height');
						var toRemove = 'px';
						var newWidthPlus = subStrWdt.replace(toRemove, '');
						var newWidthPlusInt = parseInt(newWidthPlus) - 10;
						widthPlus.css("height",newWidthPlusInt);
					}
					else
					{
						if(App.chartToolbox.btnEnable)
						{
							var widthPlus = $('#'+App.chartToolbox.imgIdTemp);//$(App.chartToolbox.imgIdTemp);//document.getElementById("widthplus");
							var subStrWdt = widthPlus.css('height');
							var toRemove = 'px';
							var newWidthPlus = subStrWdt.replace(toRemove, '');
							var newWidthPlusInt = parseInt(newWidthPlus) - 10;
							widthPlus.css("height",newWidthPlusInt);
							
						}else{
							App.chartToolbox.btnEnable = true;
							// var charData = [];
							// var tes = $( "#list-value" ).find('.chart-point-box').length;
							// var i = 0;
							// for(i=0;i<tes;i++){
								// charData.push($( "#list-value" ).find($('.chart-point-box')[i]).text());
							// }
							if(App.chartToolbox.radioChartVal == false){
								App.chartToolbox.radioChartVal = "bar";
							}
							
							// $('#list-value').children().each(function(){ 
								// App.chartToolbox.fillColor.push("#"+$(this).attr('hexcolor'));
							// });
						
							App.chartToolbox.imgIdTemp = App.addChartToServer(App.chartToolbox.charData,App.chartToolbox.radioChartVal,App.lastClickPoint.x,App.lastClickPoint.y, App.chartToolbox.widthChart, App.chartToolbox.heightChart,App.chartToolbox.fillColor);
							App.chartToolbox.widthChart = 350;
							App.chartToolbox.heightChart = 250;
						}
					}
				}
			});	
			
			$(".apply-chart-button").click(function() {
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					App.setEnableChartCreationMode(true);
				}
			});	
			
			$(".save-chart-button").click(function() {
				if(App.chartToolbox.charData == null || App.chartToolbox.charData == false){
					alert(App.localize("%data_empty_warning"));
				}else
				{
					
					App.openedTool.removeClass('active');
					App.openedTool =false;
					$( "#chart-dragable-menu" ).hide();
					
					$( "#value-chart" ).val('');
					
					if($("#gradient").is(":checked"))
					{
						// App.newPageLayers();
						// $( "#page-file-dragable-menu" ).hide(); 
						App.chartToolbox.gradient = 1;
					} 
					
					if($("#x-axis").is(":checked"))
					{
						App.chartToolbox.scale90 = 0;
					}else if($("#y-axis").is(":checked")){
						App.chartToolbox.scale90 = 1;
					}
					
					if($("#gradient").is(":checked"))
					{
						if(App.chartToolbox.startColor == false)
							App.chartToolbox.startColor = '#ffcc00';
							
						if(App.chartToolbox.endColor == false)
							App.chartToolbox.endColor = '#ffcc00';
					}
					
					
					if(App.chartToolbox.btnEnable == true || App.chartToolbox.editClick == true)
					{
						App.chartToolbox.widthChart = App.activeObject.css('width');
						App.chartToolbox.heightChart = App.activeObject.css('height');
						
						if(App.chartToolbox.radioChartVal == false){
							App.chartToolbox.radioChartVal = "bar";
						}
						App.chartToolbox.btnEnable = false;
						App.chartToolbox.editClick = false;
						App.updateChartProperty(App.chartToolbox.charData,App.chartToolbox.radioChartVal, App.activeObject.css('top'),App.activeObject.css('left'),App.chartToolbox.widthChart, App.chartToolbox.heightChart);
					}
					else
					{ 				
						if(App.chartToolbox.radioChartVal == false){
							App.chartToolbox.radioChartVal = "bar";
						}
						
						var center = App.getAbsoluteCenter();
						App.addChartToServer(App.chartToolbox.charData,App.chartToolbox.radioChartVal,center.x-parseInt(App.chartToolbox.widthChart)/2,center.y-parseInt(App.chartToolbox.heightChart)/2, App.chartToolbox.widthChart, App.chartToolbox.heightChart,App.chartToolbox.fillColor);
					}
					
					$('.chart-point-box').remove();
					App.chartToolbox.charData = false;
					App.chartToolbox.charData = [];
					App.setEnableChartCreationMode(false);
					App.chartToolbox.isOpen = 0;
				}
			});
			
			$(".cancel-chart-button").click(function() {
				var r=confirm(App.localize("%cancel_confirmation"));
				if (r==true)
				{
					App.openedTool.removeClass('active');
					App.openedTool =false;
					App.chartToolbox.charData = false;
					App.chartToolbox.charData = [];
					$("#overlay-event").hide();
					$( "#chart-dragable-menu" ).hide();
					$( "#pick-color-dragable-menu" ).hide();
					$('.chart-point-box').remove();
					App.setEnableChartCreationMode(false,"");
					App.chartToolbox.isOpen = 0;
					//hide any color picker windows if shown.
					$('.jPicker.Container').each(function(){
						if($(this).css('display') == 'block')
						{	
							$(this).css('display','none');
						}
					});
				}
				
			});		
		
		}
	}
});